package com.abel.bigwater.data.jnrq

import com.abel.bigwater.data.BcdString
import com.alibaba.fastjson.JSON
import io.netty.buffer.Unpooled
import org.junit.Assert.*
import org.junit.Test
import org.slf4j.LoggerFactory

class FLowGaugeDataTest {
    @Test
    fun testParseFlowGauge() {
        val p = JnrqPacket.parseBuffer(Unpooled.buffer().writeBytes(BcdString.toByteArray(str)))
        lgr.info(JSON.toJSONString(p, true))
        assertTrue(p.data is UploadHistoryData)
        assertEquals((p.data as UploadHistoryData).waterList?.size, 1)
    }

    companion object {
        private val lgr = LoggerFactory.getLogger(FLowGaugeDataTest::class.java)

        const val str = """68 11 55 46 aa e6 02 00 55 00 03 00 00 1b 00 00 09 09 7f 01 bb 05 95 16 00 09 10 42 01 81 37 0d
0d 16 01 e3 07 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 d6 a5 fe 6d 7c 73 df bb 7c be b7 d6 f7
be 33 d6 5d ed b6 00 00 00 00 69 f3 4e f4 00 00 00 00 bc 0d 0a
"""
    }
}